#ifndef MESH_H
#define MESH_H

#include"D3DUtility.h"
#include"Object.h"

class Mesh : public Object
{
public:
	Mesh(){ vertexBuffer = NULL; indexBuffer = NULL; vertexDecl = NULL; scale = Vector3(1.0f, 1.0f, 1.0f); }
	void Create(int nVertices, int nIndices, VertexType type);
	void CreateVertexBuffer(int nVertices);
	void CreateIndexBuffer(int nIndices);
	void SetVertexDeclaration();
	D3DXMATRIX LocalToWorldMatrix();
	void CaculateNormals();

	void SetStream();
	void Draw();
public:
	Vector3	*positionData;
	Vector2 *uvData;
	Vector3 *normalData;
	void *vertexData;
	WORD *indexData;

	IDirect3DVertexBuffer9* vertexBuffer;
	IDirect3DIndexBuffer9*  indexBuffer;

	VertexType vertexType;
	int sizeofVertex;
	IDirect3DVertexDeclaration9 *vertexDecl;

	Vector3 scale;

	int numVertices;
	int numTriangles;
};


#endif